package com.ship.contract.controller;


import com.ship.contract.service.sys.LoginRecordService;
import com.ship.contract.service.sys.SysOperationRecordService;

import com.ship.system.api.domain.SysLoginRecord;
import com.ship.system.api.domain.SysOperationRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/log")
public class LogController {

    @Autowired
    private SysOperationRecordService operationRecordService;

    @Autowired
    private LoginRecordService loginRecordService;

    /**
     * 保存系统日志
     *
     * @param sysOperLog 日志实体
     * @return 结果
     */
    @PostMapping("/operlog")
    public void saveLog(@RequestBody SysOperationRecord sysOperLog){
        operationRecordService.insertOperlog(sysOperLog);
    }

    /**
     * 保存访问记录
     *
     * @param sysLogininfor 访问实体
     * @return 结果
     */
    @PostMapping("/logininfor")
    public void saveLogininfor(@RequestBody SysLoginRecord sysLogininfor){
        loginRecordService.insertLoginLog(sysLogininfor);
    }
}
